/*	Notes:
 * 		#1: Have to set points as doubles. (ints get rounded and therefore, rounded down.)
 * 			-will be moving negatively, ONLY-with ints (effectively moving at -1 pixel per cycle, at this rate)
 * 		#2: Any diagonal is just x * sqrt(2)...
 * 
 */

import java.awt.*;

public class LinearPath extends Path {

	private double direction; // 0 to 360, technically... will work if over or under
	
	public LinearPath(double cstartX, double cstartY, double cd){
		super(cstartX, cstartY);
		direction = cd;
	}
	// traversalSpeed will be pixels/second... so long l must be divided by what, 100,000,00?
	public Point addTravelDistance(long l, int traversalSpeed){
		double timeInSeconds = (double)(l)/1000000000;
		double elapsedDistance = traversalSpeed * timeInSeconds;
		setElapsedTime(getElapsedTime()+l);
		//System.out.print(getElapsedDistance() + " to ");
		setElapsedDistance(getElapsedDistance()+(double)(traversalSpeed)*timeInSeconds);
		//System.out.println(getElapsedDistance() + ", " + timeInSeconds + ", " + traversalSpeed);
		double adjustX = 0.0;
		double adjustY = 0.0;
		if((direction != 180.0) && (direction != 360.0))
			adjustY = -(elapsedDistance * Math.sin(Math.toRadians(direction)));
		if((direction != 90.0) && (direction != 270.0))
			adjustX = elapsedDistance * Math.cos(Math.toRadians(direction));
		System.out.println(Math.PI);
		
		// additively becoming less and less accurate D: (if I add onto the current point)
		
		//double hurrrrrr = Math.cos(Math.toRadians(direction));
		//System.out.println(hurrrrrr + ", " + direction);
		
		/*for(int i=0;i<360;i+=45)
		{
			System.out.println("i = " + i + " > sin(i) = " + Math.sin(Math.toRadians(i)) + ", cos(i) = " + Math.cos(Math.toRadians(i)));
		} // */
		
		System.out.println(direction + ": " + elapsedDistance + "@ ( "+ adjustX + " , " + adjustY + " )");
		
		setCurrentX(getCurrentX()+adjustX);
		setCurrentY(getCurrentY()+adjustY);
		
		//setCurrentPoint(new Point((int)(getCurrentPoint().getX() + adjustX), (int)(getCurrentPoint().getY() + adjustY)));
		
		//System.out.println(direction);
		return new Point((int)getCurrentX(),(int)getCurrentY());
	}
	
	public double getDirection(){return direction;}
	
	public void setDirection(double sd){direction = sd;}
}